package com.leessy.r229.server

import com.leessy.r229.server.http.databean.HeartBeatBean
import com.leessy.r229.server.http.databean.ResponesBean
import io.reactivex.rxjava3.core.Observable
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query
import retrofit2.http.Streaming
import retrofit2.http.Url

/**
 * @author : Created by liucheng. on 2021/01/04
 * @description : consumer related business interface
 */
interface HttpApi {
    companion object {
        const val CONSUM_TRANSACTIONS = "hpt/v1/ConsumTransactions"
        const val GET_CURRENT_TIME = "hpt/v1/CurrentTime"//check connection status
        const val TRANSCOUNT = "hpt/v1/transcounts" //statistics of current consumption
        const val TRANSACTION = "hpt/v1/Transaction" //word record information query
        const val OFFLINERECORD = "hpt/v1/Offlines" //upload offline data
        const val COMIDCODES = "hpt/v1/Comidcodes" //getVerificationCode
        const val MENUS = "hpt/v1/Menus" //menu
        const val SETTING_GET = "hpt/v2/Settings/Get"
        const val FACE_SYNCTASKS = "/hpt/v2/Accounts/FaceSyncTasks"

        const val CONSUMPATION_LOAD_FACE = "hpt/v2/Accounts/FaceSyncTasks"//同步人员数据 返回同步人员状态
        const val CONSUMPATION_UPLOAD_IMAGE = "hpt/v2/Accounts/UploadIdentifyImage"//上次识别图片记录
        const val LISTCARD = "hpt/v2/Terminals/ListCard"//卡号

        const val HEARTBEAT = "/api/Device/heartbeat"//心跳
        const val STATUS = "/api/Device/status"//状态上传
        const val GETOSSSTS = "/api/Device/osssts"//oss token
        const val POSTLOGS = "/api/Device/logs"//上传log
    }

    @POST(STATUS)
    fun status(@Body params: RequestBody): Observable<ResponesBean>

    @POST(HEARTBEAT)
    fun heartbeat(@Body params: RequestBody): Observable<HeartBeatBean>

    @POST(POSTLOGS)
    fun postfile(@Body params: RequestBody): Observable<ResponesBean>


    @Streaming
    @GET
    fun download(@Url url: String): Observable<ResponseBody>


    /**
     * sync relevant face data of this device
     */
    @GET(FACE_SYNCTASKS)
    fun faceSyncTasks(@Query("clientNos") clientNos: String)

    /**
     * returns the status of synchronized data
     */
    @POST(FACE_SYNCTASKS)
    fun faceSyncTasksStatus()


    /**
     * 人脸数据处理结果
     */
    @POST(CONSUMPATION_LOAD_FACE)
    fun faceSyncTasks(@Body requestBody: RequestBody): Call<Any>

    /**
     * upload face recognition record picture
     * server success return : "{}"
     */
    @POST(CONSUMPATION_UPLOAD_IMAGE)
    fun uploadReordimg(@Body requestBody: RequestBody): Observable<Any>

    /**
     * upload face recognition record picture
     * server success return : "{}"
     */
//    @GET(SETTING_GET)
//    fun getSetting(): Observable<ParamsDeviceBean>
}